
<?php include './application/views/top.php'; ?>
<script src="/static/js/gsdai.js"></script>
<script src="/static/js/ajaxfileupload.js"></script>
<script src="/static/js/My97DatePicker/WdatePicker.js"></script>
<script src="/static/js/formCheck.js"></script>

<div class="clear"></div>
<div class="user_bottom all"></div>
<div class="clear h50"></div>
<div class="layout uc">
	<?php include './application/views/user/left.php'; ?>
	<div class="right">
		<div class="menu_list"><?php include './application/views/user/menu.php'; ?></div>
        <div class="cont">
        	<ul class="tbt">
	            <?php if($type == 1 || $type == 2 || $type == 3){?>
            	<li class="w118">标题</li>
                <li class="w100">类型</li>
                <li class="w120">金额</li>
                <li class="w120">年利率</li>
                <li class="w120">期限</li>
                <li class="w120"><?php if($type == 1){?>审核时间<?php }elseif ($type == 2){?>发布时间<?php }elseif($type == 3){?>复审时间<?php }?></li>
                <?php } else {?>
            	<li class="w198">标题</li>
                <li class="w110">类型</li>
                <li class="w130">金额</li>
                <li class="w130">年利率</li>
                <li class="w130">期限</li>
                <?php }?>                
				<li class="w120">进度</li>
                <li class="w100 npr">操作</li>
			</ul>
            <?php $i=0; foreach($borrow_list as $borrow){?>
        	<ul class="tbc">
            	<?php if($type == 1 || $type == 2 || $type == 3){?>
            	<li class="w118"><a href="/borrow/obj/<?php echo $borrow['id'];?>" target="_blank"><?php echo $borrow['title'];?></a></li>
            	<li class="w100"><?php echo $borrow_type[$borrow['ftype']];?></li>
            	<li class="w120">&yen;<?php echo number_format($borrow['account'],2);?>元</li>
                <li class="w120"><?php echo $borrow['apr'];?>%</li>
                <li class="w120"><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天';}else{ echo $borrow['time_limit'].'个月';}?></li>
            	<li class="w120"><?php if($type == 1){echo date('Y-m-d',$borrow['verify_time']);}elseif ($type == 2){echo date('Y-m-d',$borrow['add_time']); }elseif ($type == 3){echo date('Y-m-d',$borrow['repayment_time']); }?></li>
                <?php } else {?>
            	<li class="w198"><a href="/borrow/obj/<?php echo $borrow['id'];?>" target="_blank"><?php echo $borrow['title'];?></a></li>
            	<li class="w110"><?php echo $borrow_type[$borrow['ftype']];?></li>
            	<li class="w130">&yen;<?php echo number_format($borrow['account'],2);?>元</li>
                <li class="w130"><?php echo $borrow['apr'];?>%</li>
                <li class="w130"><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天';}else{ echo $borrow['time_limit'].'个月';}?></li>
                <?php }?>
                <li class="w120"><?php echo number_format(round($borrow['account_yes']/$borrow['account']*100, 2),2);?>%</li>
            	<li class="w100 npr"><?php if($borrow['fstatus']==0 || $borrow['fstatus']==1){?><a href="javascript:if(confirm('你确定撤回？')){withdraw(<?php echo $borrow['id'];?>);}">撤标</a><?php }?></li>
			</ul>
            <?php $i++; }?>
        </div>
        <div class="clear h30"></div>
        <div class="page">
            <div class="pagination">
            <?php echo $this->pagination->create_links();?>
            </div>
        </div>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>
<script>
function withdraw(borrow_id){
	$.ajax({
		type: "get",
		url: "/userborrow/withdraw/"+borrow_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("撤标成功！");
				$("#borrow_"+borrow_id).hide();
			}else{
				$("#msg").html("撤标失败，请联系管理员！");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
function repay(repayment_id){
	$.ajax({
		type: "get",
		url: "/userborrow/repayment/"+repayment_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("还款成功！");
				$("#borrow_"+borrow_id).hide();
			}else{
				$("#msg").html(msg);
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
</script>